package cn.zzh.test;

import cn.zzh.dao.AddSpring;
import cn.zzh.dao.AddSpringImp02;
import cn.zzh.service.AddService;

import cn.zzh.user.User;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class T01 {
    @Test
    public void Test01(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Spring01.xml");
        AddSpring addSpring =(AddSpring) context.getBean("addSpringImp01");
        addSpring.getUser();

    }
    @Test
    public void Test02(){
        AddSpringImp02 imp02 = new AddSpringImp02();
        imp02.getUser();
    }

    /**
     * set方法注入
     */
    @Test
    public void Test03(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Spring01.xml");
        AddService addService = context.getBean("addService", AddService.class);
        addService.Add();
    }

    /**
     * 构造方法注入
     */
    @Test
    public void Test04(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Spring01.xml");
        AddService addService01 = context.getBean("addService01", AddService.class);
        addService01.Add();
    }

    /**
     * p方法注入
     */
    @Test
    public void Test05(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Spring01.xml");
        AddService addService02 = context.getBean("addService02", AddService.class);
        addService02.Add();
    }

    /**
     * 基本数据类型注入
     */
    @Test
    public void Test06(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Spring01.xml");
        User user = context.getBean("user", User.class);
        System.out.println(user);
    }



}
